

#pragma once

#ifndef __GC_LPR_H__
#define __GC_LPR_H__

#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include "json.hpp"
#include "httplib.h"
#include "types.h"
#include "utils_misc.h"
// #include "crnn.h"
#include "lpr_infer_api.h"
#include "nnie_service.h"

extern GC_APP_CONFIG gc_app_config;
extern std::vector<std::string> PLATE_CHINESE_CHAR_LIST;

using namespace std;
using namespace cv;
using namespace HWApp;

namespace gc
{
    class GCLpr : public Singleton<GCLpr>
    {
        public:
            GCLpr();
	        virtual ~GCLpr(void);
            nlohmann::json lpr_remote(cv::Mat &img);
            nlohmann::json lpr_remote_batch(std::vector<std::string>& img_base64_list);

            nlohmann::json lpr_local(cv::Mat &img, GC_PLATE_TYPE plate_type = GC_PLATE_TYPE::SINGLE);
            nlohmann::json lpr_local_batch(std::vector<cv::Mat>& img_list);
            nlohmann::json lpr_local_batch(std::vector<cv::Mat>& img_list, std::vector<GC_PLATE_TYPE>& plate_type_list);

        private: 
            httplib::Client* httpClient(void);
            GC_PLATE_COLOR plate_img_color(cv::Mat& img);
        private:
            httplib::Client *m_client;
            // PlateCrnn crnn;
            std::shared_ptr<DetectRecPlate> m_forwarder;
            NNIE m_nnie;
    };
}

#endif